<?php
define('ROOT_DIR', $_SERVER['DOCUMENT_ROOT'].'/');
$path = ROOT_DIR.'setting.php';
$settingsContent = file_get_contents($path);
$titles = $_POST['title'];
$admins = $_POST['admin'];
$calls = $_POST['call'];
$setting_dexs_array = <<<EOT
\$redis_pz  = array(
    'host'     => '$titles',
    'port'     => '$admins',
    'password' => '$calls'
);
EOT;
$pattern = '/\$redis_pz\s*=\s*array\s*\(\s*[^;]*\s*\);/s';
$replacement = $setting_dexs_array;
$updatedSettingsContent = preg_replace($pattern, $replacement, $settingsContent);
file_put_contents($path, $updatedSettingsContent);
echo '<script>alert("修改成功");window.location.href="../../pzsetting.php?s=redis";</script>';